#! /usr/bin/python3

import requests
import os

if __name__ == '__main__':

    username = "jin1213107752"
    repository_name = input("请输入想要删除的仓库名:\n")
    fileName = "access_token.txt"

    if os.path.exists(fileName):
        with open(fileName, 'r', encoding='utf-8') as f:
            access_token = f.read().strip()
    else:
        access_token = input("请输入token:\n")

    url = "https://gitee.com/api/v5/repos/" + username + "/" + repository_name + "?access_token=" + access_token
    header = {
        "Content-Type": "application/json;charset=UTF-8"
    }

    response = requests.delete(
        url=url,
        headers=header,
    )

    print("Response code:", response.status_code)
    if response.status_code == 204:
        print("删除成功")
    else:
        print(response.text)
